<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>帐号设置</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="{{ static('images/logo.ico') }}"/>
    <meta name="keywords" content="小宅社区">
    <meta name="description" content="小宅社区">
    <link rel="stylesheet" href={{ static('js/layui/css/layui.css') }}>
    {#  <link rel="stylesheet" href="../res/css/global.css">#}
    <script src="{{ static('js/layui/jquery-3.3.1.min.js') }}"></script>
    <link rel="stylesheet" href={{ static('css/global.css') }}>
</head>
<body>
<div class="fly-header layui-bg-black">
    <div class="layui-container">
        <a class="fly-logo" href="/">
            {#            <img src="../res/images/logo.png" alt="layui">#}
            <img src={{ static('images/logo.png') }} alt="layui">
        </a>
        <ul class="layui-nav fly-nav layui-hide-xs">
            <li class="layui-nav-item layui-this">
                <a href="/"><i class="iconfont icon-jiaoliu"></i>交流</a>
            </li>
            <li class="layui-nav-item">
                <a href="/case/case"><i class="iconfont icon-iconmingxinganli"></i>案例</a>
            </li>

        </ul>

        <ul class="layui-nav fly-nav-user">
            {% if user.username %}
                <li class="layui-nav-item">
                    <a class="fly-nav-avatar" href="/userindex">
                        <cite class="layui-hide-xs">{{ user.username }}</cite>
                        <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：layui 作者"></i>
                        <i class="layui-badge fly-badge-vip layui-hide-xs">VIP{{ user.is_vip }}</i>
                        <img src="{{ user.images_url }}">
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="user/set"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
                        <dd><a href="user/index"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a>
                        </dd>
                        <dd><a href="user/home?u={{ user.id }}"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a>
                        </dd>
                        <hr style="margin: 5px 0;">
                        <dd><a href="/logout/" style="text-align: center;">退出</a></dd>
                    </dl>
                </li>
            {% else %}
                <li class="layui-nav-item">
                    <a class="iconfont icon-touxiang layui-hide-xs" href="/login"></a>
                </li>
                <li class="layui-nav-item">
                    <a href="/login">登入</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/reg">注册</a>
                </li>
                <li class="layui-nav-item layui-hide-xs">
                    <a href="/app/qq/" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入"
                       class="iconfont icon-qq"></a>
                </li>
                <!-- 登入后的状态 -->

            {% endif %}
        </ul>
    </div>
</div>

<div class="layui-container fly-marginTop fly-user-main">
    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
        <li class="layui-nav-item">
            <a href="/user/home?u={{ user.id }}">
                <i class="layui-icon">&#xe609;</i>
                我的主页
            </a>
        </li>
        <li class="layui-nav-item ">
            <a href="/user/index">
                <i class="layui-icon">&#xe612;</i>
                用户中心
            </a>
        </li>
        <li class="layui-nav-item layui-this">
            <a href="/user/set">
                <i class="layui-icon">&#xe620;</i>
                基本设置
            </a>
        </li>
        <li class="layui-nav-item icon-tiezi">
            <a href="/user/user_message">
                <i class="layui-icon">&#xe621;</i>
                我的贴子
            </a>
        </li>
        <li class="layui-nav-item">
            <a href="/user/collects">
                <i class="layui-icon">&#xe600;</i>
                我的收藏
            </a>
        <li class="layui-nav-item">
            <a href="/user/follow">
                <i class="layui-icon">&#xe654;</i>
                我的关注
            </a>
        </li>
        <li class="layui-nav-item">
            <a href="/user/fly_kiss">
                <i class="layui-icon">&#xe657;</i>
                飞吻商城
            </a>
        </li>

        </li>
    </ul>

    <div class="site-tree-mobile layui-hide">
        <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>

    <div class="site-tree-mobile layui-hide">
        <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>


    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title" id="LAY_mine">
                <li class="layui-this" lay-id="info">我的资料</li>
                <li lay-id="avatar">头像</li>
                <li lay-id="pass">密码</li>

            </ul>
            <div class="layui-tab-content" style="padding: 20px 0;">
                <div class="layui-form layui-form-pane layui-tab-item layui-show">
                    <form method="post">
                        <div class="layui-form-item">
                            <label for="L_email" class="layui-form-label">邮箱</label>
                            <div class="layui-input-inline">
                                {% if user.email %}
                                    <input type="text" id="L_email" name="email" required lay-verify="email"
                                           autocomplete="off" value="{{ user.email }}" class="layui-input">
                                {% else %}
                                    <input type="text" id="L_email" name="email" required lay-verify="email"
                                           autocomplete="off" value="{{ user.email }}" class="layui-input">
                                {% endif %}

                            </div>
                            <div class="layui-form-mid layui-word-aux">请在邮箱修改后，前往用户中心进行验证
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_username" class="layui-form-label">昵称</label>
                            <div class="layui-input-inline">
                                {% if user.username %}
                                    <input type="text" id="L_username" name="username" required lay-verify="required"
                                           autocomplete="off" value="{{ user.username }}" class="layui-input">
                                {% else %}
                                    <input type="text" id="L_username" name="username" required lay-verify="required"
                                           autocomplete="off" value="" class="layui-input">
                                {% endif %}
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    {% if user.gender=="1" %}
                                        <input type="radio" class="gender" name="sex" value="0" title="男">
                                        <input type="radio" class="gender" name="sex" value="1" checked title="女">
                                        <input type="radio" class="gender" name="sex" value="2" title="保密">
                                    {% elif user.gender == "0" %}
                                        <input type="radio" class="gender" name="sex" value="0" checked title="男">
                                        <input type="radio" class="gender" name="sex" value="1" title="女">
                                        <input type="radio" class="gender" name="sex" value="2" title="保密">
                                    {% else %}
                                        <input type="radio" class="gender" name="sex" value="0" title="男">
                                        <input type="radio" class="gender" name="sex" value="1" title="女">
                                        <input type="radio" class="gender" name="sex" value="2" checked title="保密">
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_city" class="layui-form-label">城市</label>
                            <div class="layui-input-inline">
                                {% if user.city %}
                                    <input type="text" id="L_city" name="city" autocomplete="off"
                                           value="{{ user.city }}"
                                           class="layui-input">
                                {% else %}
                                    <input type="text" id="L_city" name="city" autocomplete="off" value=""
                                           class="layui-input">
                                {% endif %}
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label for="L_sign" class="layui-form-label">签名</label>
                            <div class="layui-input-block">
                                {% if user.signature %}
                                    <textarea placeholder="{{ user.signature }}" id="L_sign" name="sign"
                                              autocomplete="off" class="layui-textarea"
                                              style="height: 80px;"></textarea>
                                {% else %}
                                    <textarea placeholder="随便写些什么刷下存在感" id="L_sign" name="sign" autocomplete="off"
                                              class="layui-textarea" style="height: 80px;"></textarea>
                                {% endif %}
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" onclick="bbb()" key="set-mine" lay-filter="*" lay-submit>确认修改
                            </button>
                        </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                    <div class="layui-form-item">
                        <div class="avatar-add">
                            <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过5MB</p>
                            <button type="button" class="layui-btn upload-img">
                                <i class="layui-icon">&#xe67c;</i>上传头像
                            </button>
                            <img src="{{ user.images_url }}">
                            <span class="loading"></span>
                        </div>
                    </div>
                </div>

                <div class="layui-form layui-form-pane layui-tab-item">
                    <form action="/user/repass" method="post">
                        <div class="layui-form-item">
                            <label for="L_nowpass" class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_nowpass" name="nowpass" required lay-verify="required"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_pass" class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_pass" name="pass" required lay-verify="required"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_repass" class="layui-form-label">确认密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="L_repass" name="repass" required lay-verify="required"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">重复新密码</div>
                        </div>
                        <div class="layui-form-item">
                            <input class="layui-btn" onclick="aaa()" style="width:120px;" value="确认修改" readonly>

                        </div>
                    </form>
                </div>


            </div>

        </div>
    </div>
</div>
</div>

<div class="fly-footer">
    <p><a href="#">小宅论坛</a> 2019 &copy; <a href="#">小宅娱乐出品</a>皖ICP备19010957号-1</p>
</div>

<script src={{ static('js/layui/layui.js') }}></script>
<script>
    function aaa() {
        alert("aa");
        var old_pwd = document.getElementById("L_nowpass").value;
        var pwd1 = document.getElementById("L_pass").value;
        var pwd2 = document.getElementById("L_repass").value;
        if (!old_pwd) {
            alert("请输入旧密码");
            return ""
        } else if (!pwd1) {
            alert("请输入新密码");
            return ""
        } else if (!pwd2) {
            alert("请重复新密码");
            return ""
        }
        var params = {
            "old_pwd": old_pwd,
            "pwd1": pwd1,
            "pwd2": pwd2
        };
        alert(old_pwd);
        $.ajax({
            url: "/user/repass",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json",
            success: function (resp) {
                if (resp.status == "0") {
                    alert("修改成功");
                    window.location.href = '/logout';
                } else {
                    // 用户登录
                    alert(resp.msg);
                }
            }
        })
    }

    function bbb() {
        var email = document.getElementById("L_email").value;
        var user = document.getElementById("L_username").value;
        var sign = document.getElementById("L_sign").value;
        var city = document.getElementById("L_city").value;

        var gender = $(".gender:checked").val();
        var params = {
            "email": email,
            "username": user,
            "sign": sign,
            "city": city,
            "gender": gender
        };
        $.ajax({
            url: "/user/sets",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json",
            success: function (resp) {
                if (resp.status == "0") {
                    alert("修改成功");
                    location.href = '/user/index';
                } else {
                    // 用户登录
                    alert(resp.msg);
                }
            }
        })
    }

    layui.cache.page = 'user';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '../../res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };
    layui.config({
        base: '../../static/res/mods/'
    }).extend({
        fly: 'index'
    }).use('fly');
</script>

</body>
</html>

